package com.neutech.neusys.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.neutech.neusys.service.SysUserService;
import com.neutech.po.User;
import com.neutech.vo.ViewData;

@RestController
//@CrossOrigin("http://localhost:8081")
@RequestMapping("/his/sys")
public class SysUserController {
	@Autowired
	private SysUserService sysUserService;
	
	//增加新用户
	@RequestMapping(value="/addNewUser",method=RequestMethod.POST)
	public @ResponseBody User addNewUser(@RequestBody User user){
		System.out.println(user.getUserName());
		sysUserService.addNewUser(user);
		User reuser = new User();
		reuser.setUserName("");
		return reuser;
	}
	
	//查询用户
	@RequestMapping(value="/getUser")
	public @ResponseBody ViewData getUser(@RequestParam Map<String,Object> map){
		return sysUserService.getUser(map);
	}
	
	//修改用户
	@RequestMapping(value="/updateNewUser",method=RequestMethod.POST)
	public User updateNewSgory (@RequestBody User user) throws Exception{
		System.out.println("1:"+user);
		user = sysUserService.updateNewUser(user);
		System.out.println(user.getUserName());
		return user;
		
	}
	//删除用户
	@RequestMapping(value = "/deleteUser",method=RequestMethod.POST)
	public User deleteUser (@RequestBody User user) throws Exception{
		user = sysUserService.deleteUser(user);
		return user;
	}
}
